package com.example.swaggertest.controller;

import com.alibaba.fastjson.JSON;
import com.example.swaggertest.pojo.Student;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Api(value = "测试数据操作类",tags = {"测试数据操作接口"})
public class HelloController {

    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }

    @PostMapping("/Student")
    public Map test(@RequestBody Student student){
        String s = JSON.toJSONString(student);
        System.out.println("类转json"+s);

        Map parse = JSON.parseObject(s,Map.class);
        System.out.println("json转类"+parse);

        return parse;
    }

    @GetMapping("/hello1")
    public String hello1(){
        return "hello1";
    }
}
